package swing.samples.java2sdotcom.progessMonitor.copyexample;

import java.awt.BorderLayout;
import java.awt.Dimension;
import java.awt.Toolkit;

import javax.swing.JFrame;

public class CopyFrame extends JFrame {  
    private ContentPanel contentPanel;  
    private ProgressBarPanel progressBarPanel;  
      
    public CopyFrame() {  
        super("文件拷贝小程序");  
        init();  
    }  
      
    private void init() {  
        this.setSize(350,250);  
        this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);  
        this.setResizable(false);  
          
        contentPanel = new ContentPanel();  
        progressBarPanel = new ProgressBarPanel();  
          
        contentPanel.setProgressBarPanel(progressBarPanel);  
          
        Toolkit kit = Toolkit.getDefaultToolkit();  
        Dimension screen = kit.getScreenSize();  
        Dimension frame = this.getSize();  
          
        if (screen.width < frame.width) {  
            frame.width = screen.width;  
        }  
          
        if (screen.height < frame.height) {  
            frame.height = screen.height;  
        }  
          
        int locationWidth = (screen.width - frame.width) / 2;  
        int locationHeight = (screen.height - frame.height) / 2;  
        this.setLocation(locationWidth, locationHeight);  
          
        this.getContentPane().add(contentPanel);  
        this.getContentPane().add(progressBarPanel, BorderLayout.SOUTH);  
        this.setVisible(true);  
    }  
      
    public static void main(String[] args) {  
        new CopyFrame();  
    }  
}  
